class Solution:
    def strStr(self, haystack: str, needle: str) -> int:
        list1 = list(haystack)
        list2 = list(needle)
        flag1 = list2[0]
        fflag = -1
        res=0
        for n in range(len(list1)):
            if (fflag == 1):
                return n - 1
            if (list1[n] == flag1):
                if(len(list1[n:])>=len(list2)):
                    res=n
                    fflag = 1
                    for i in range(len(list2)):
                        if (list2[i] != list1[n + i]):
                            fflag = -1
                            break
                else: return -1
        if(fflag==1):
            return res
        return -1


lll = Solution()
print(lll.strStr('qweqwa', 'a'))
